#include <iostream>
#include <fstream>
#include <direct.h>
#include <windows.h>
#include <vector>
#include <algorithm>
#include <CXX/Objects.hxx>

using namespace std;

void setPythonHome()
{
	wchar_t buf[256];
	_wgetcwd(buf, 256);
	wsprintfW(buf, L"%s/../../3rdparty/Python38", buf);
	Py_SetPythonHome(buf);
	Py_Initialize();
}

void invokeC()
{
	char cmd[256];
	_getcwd(cmd, 256);
	sprintf(cmd, "%s\\..\\bin\\debug\\Module_d.pyd", cmd);
	//HINSTANCE hModule = LoadLibraryEx(cmd,NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
	HINSTANCE hModule = LoadLibrary(cmd);
	if (hModule)
	{
		auto func = GetProcAddress(hModule, "PyInit_Module");
		if (func)
		{
			func();
		}
	}

}
void invokePython()
{

	PyRun_SimpleString("import sys");
	PyRun_SimpleString("sys.path.append('./')");
	PyRun_SimpleString("print(sys.path)");

	PyObject* presult, * dict, * module;
	char cmd[256];
	_getcwd(cmd, 256);
	sprintf(cmd, "%s\\..\\bin\\debug\\Module", cmd);
	//PyRun_SimpleString(cmd);
	/*PyObject* modules = PyImport_GetModuleDict();
	module = PyDict_GetItemString(modules, "Module");*/
	module = PyImport_ImportModule("Module");
	if (module)
	{

	}
}

int main(int args, char* argc[])
{
	setPythonHome();
	//invokePython();
	invokeC();
	return 0;
}